#pragma once

#include "FFMpegInstance.h"
#define STREAM_FRAME_RATE 10

class CFLVWriter
{
public:
	CFLVWriter(void);
	~CFLVWriter(void);
private:

	AVFormatContext* m_pFmtCtx;
	AVOutputFormat*  m_pOutFmt;
	AVStream *m_pAudioSt, *m_pVideoSt;
	CodecID			m_vCodecID, m_aCodecID;
	
	BOOL  m_bInitialized;
	char            m_fileName[100];
public:
	BOOL Init(char fileName[], CodecID vCodecID, CodecID aCodecID, char* streamName);
	BOOL WriteVideo(unsigned char* lpData, long biSizeImage, BOOL keyFrame);
	BOOL WriteAudio(unsigned char* lpData, long size);
	void Close();

private:
	AVStream *add_video_stream(AVFormatContext *oc, CodecID codec_id);
	AVStream *add_audio_stream(AVFormatContext *oc, CodecID codec_id);
	void fn_insertStreamName(ByteIOContext *pb, char* streamName);
};
